﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System;
using System.Threading;
using System.ComponentModel;
using BrainTechLLC.ThreadSafeObjects;
using System.Runtime.Serialization;

namespace BrainTechLLC
{
    public static class SerializableTypeStorage
    {
        public static ThreadSafeLookup<int, Type> MessageTypeToTypeLookup = new ThreadSafeLookup<int, Type>();

        public static bool RegisterType(this int messageType, Type type)
        {
            if (MessageTypeToTypeLookup.ContainsKey(messageType))
                return false;

            MessageTypeToTypeLookup.AddOrSet(messageType, type);
            return true;
        }

        public static Type TypeFromMessageType(this int i)
        {
            return MessageTypeToTypeLookup[i];
        }
    }
}
